package com.gec.hawaste.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.hawaste.entity.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gec.hawaste.vo.SysRoleDo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * <p>
 * 角色表 Mapper 接口
 * </p>
 *
 * @author chenxys
 * @since 2022-07-01
 */
public interface SysRoleMapper extends BaseMapper<SysRole> {
    @Select("SELECT sys_role.*, " +
            "   sys_office.`name` office_name " +
            "   FROM sys_role " +
            "   LEFT JOIN sys_office " +
            "   ON sys_role.office_id=sys_office.id " +
            "   AND sys_role.del_flag=0 AND sys_office.del_flag=0 ${ew.customSqlSegment}")
    IPage<SysRoleDo> selectByCondition(IPage<SysRoleDo> page, @Param("ew") Wrapper ew);

    @Select("SELECT sys_role.*," +
            "   sys_office.`name` office_name" +
            "    FROM sys_role" +
            "   LEFT JOIN sys_office" +
            "   ON sys_role.office_id=sys_office.id" +
            "   AND sys_role.del_flag=0 AND sys_office.del_flag=0 ${ew.customSqlSegment}")
    SysRoleDo getByRoleId(@Param("ew") Wrapper ew);
}
